﻿using System;
using System . Collections . Generic;
using System . Collections . ObjectModel;
using System . IO;
using System . Linq;
using System . Runtime . InteropServices . WindowsRuntime;
using System . Text;
using System . Threading;
using System . Threading . Tasks;
using System . Xml . Linq;
using WenceyWang . RichMan4L . App . Logic;
using Windows . Foundation;
using Windows . Foundation . Collections;
using Windows . Foundation . Metadata;
using Windows . UI . ViewManagement;
using Windows . UI . Xaml;
using Windows . UI . Xaml . Controls;
using Windows . UI . Xaml . Controls . Primitives;
using Windows . UI . Xaml . Data;
using Windows . UI . Xaml . Input;
using Windows . UI . Xaml . Media;
using Windows . UI . Xaml . Navigation;


namespace WenceyWang . RichMan4L . App . Pages
{
	/// <summary>
	/// 起始动画页
	/// </summary>
	public sealed partial class StartPage : Page
	{
		public StartPage ( )
		{
			this . InitializeComponent ( );
		}

		List<Task> taskToWait;

		private async void Page_Loaded ( object sender , RoutedEventArgs e )
		{
			if ( ApiInformation . IsMethodPresent ( "Windows.UI.ViewManagement.StatusBar" , "HideAsync" ) )
			{
				//await StatusBar . GetForCurrentView ( ) . HideAsync ( );
			}
			
			StartStoryBoard . Completed += StartStoryBoard_Completed;
			StartStoryBoard . Begin ( );
			taskToWait = new List<Task> ( );
			taskToWait . Add ( GameSaying . LoadSayings ( ) );
			taskToWait . Add ( Players . Models . PlayerModelProxy . LoadPlayerModels ( ) );
			taskToWait . Add ( Maps . MapProxy . LoadMaps ( ) );
		}

		private void StartStoryBoard_Completed ( object sender , object e )
		{
			Task . WaitAll ( taskToWait . ToArray ( ) );
			PageNavigateHelper . Navigate ( typeof ( MainPage ) , null , "Cyan" , LeaveStoryBoard , BackGroundRect , Frame );
		}
	}
}
